from django.db import models
from apps.common.base.models import BaseModel

class Sku(BaseModel):
    status = (
        (0, "关闭"),
        (1, "正常"),
    )
    item = models.ForeignKey('Item', related_name="item_sku", verbose_name='商品', on_delete=models.SET_NULL, null=True,
                             blank=True, db_constraint=False)

    skuNum = models.CharField("sku编号", max_length=200, blank=True, null=True)
    specValues = models.CharField("规格值", max_length=200, blank=True)
    coverUrl = models.CharField("封面图", max_length=200, blank=True)
    costPrice = models.DecimalField("成本价", max_digits=10, decimal_places=2, default=0)
    marketPrice = models.DecimalField("市场价", max_digits=10, decimal_places=2, default=0)
    sellingPrice = models.DecimalField("销售价", max_digits=10, decimal_places=2, default=0)
    sales = models.IntegerField("销量", default=0)
    stock = models.IntegerField("库存", blank=True, default=0)
    status = models.IntegerField("状态", choices=status, default=1)

    class Meta:
        verbose_name = 'Sku'
        verbose_name_plural = verbose_name
